package com.ecable.action;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import com.ecable.daoImpl.ConnectionDaoImpl;
import com.ecable.daoImpl.ProfileDAO;
import com.ecable.util.UtilConstants;

public class UpdateCustomerConnStatusAction extends HttpServlet {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	public void doGet(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		doPost(request, response);
	}
	public void doPost(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		String path = "";
		boolean flag = false;
		HttpSession session = request.getSession();
		int connid = Integer.parseInt(request.getParameter("connid"));

		try {

			flag = new ConnectionDaoImpl().updateOperatorStatus(connid);
			System.out.println(flag);
			if (flag) {

				request.setAttribute("status1",
						UtilConstants._UPDATE_REQUEST_STATUS);
				path = UtilConstants._DISPLAY_OPERATOR_ACTION;

			} else {

				request.setAttribute("status",
						UtilConstants._UPDATE_REQUEST_STATUS_FAIL);
				path = UtilConstants._DISPLAY_OPERATOR_ACTION;

			}

		} catch (Exception e) {

			request.setAttribute("status",
					UtilConstants._UPDATE_REQUEST_STATUS_FAIL);
			path = UtilConstants._DISPLAY_OPERATOR_ACTION;

		}
		RequestDispatcher rd = request.getRequestDispatcher(path);

		rd.forward(request, response);
	}

}
